$(function() {

	$.get(serv.listPptFolder, function(d) {
		if(d.success) {
			renderTree(d.data);
		}
	});
})

/**
 * 
 */
function renderTree(treeData) {
	var tree = new LocalTree();
	tree.addData(treeData);
	tree.renderTo(".tree", function(td) {
		if (td.leaf) {
			$.get(serv.listFiles, {baseUrl: td.url}, function(pptData) {
				if (pptData.success) {
					renderImage(pptData.data);
				}
			})
		}
	});
}

/**
 * 生成分页条
 */
function renderImage(imageList) {
	if (imageList && imageList.length>0) {
		var pageToolbar = new PageToolbar(9);
		for (var i in imageList) {
			pageToolbar.addData({imgUrl: imageList[i].url});
		}

		pageToolbar.renderTo(".content .imgToolbar", function(data) {
			$(".content img").attr("src", data.imgUrl);  //切换图片
			$.get(serv.setPPT, {imagePath:data.imgUrl}); //设置当前教学PPT图片
		});
	}
}


